#!/bin/bash

source "$METIS_HOME"metis.config

#scanType is set to default
scanType=1

while getopts "h:fds:o:l:" key ; do
    case "${key}" in
        h) targetHost=${OPTARG};;
        f) scanType=0;;	# fast
	d) scanType=1;; # default
	s) speed=${OPTARG};;
	o) outputDir=${OPTARG};;
	l) loggingDir=${OPTARG};;
    esac
done

if [ ! ${targetHost} ]; then
	echo "Error - Host has not been specified"
	exit
fi

mkdir ${outputDir}/${targetHost} &>/dev/null

# until there is a control file keep sleeping
until cat "$controlFile" 2> /dev/null
do 
	echo "Pentest paused - to resume create a file at ${controlFile}"
	sleep 30;
done

if [ ${scanType} -eq 0 ]; then
	nmap -sS -sV -vv -PN -$speed -n -F -oA "${outputDir}/${targetHost}/nmap-sSV-Fast-${targetHost}" "$targetHost" &> "${loggingDir}/nmap-sSV-Fast-${targetHost}.log"
else
	nmap -sS -sV -vv -PN -$speed -n -oA "${outputDir}/${targetHost}/nmap-sSV-Default-${targetHost}" "$targetHost" &> "${loggingDir}/nmap-sSV-Default-${targetHost}.log"
fi
	

